<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::get('/hello', function () {
    return "hello";
});
// 多个请求方式
Route::match(['get', 'post'], 'text1', function () {
    return "通过match()访问";
});
Route::any('text2', function () {
    return "通过any方法访问";
});
//路由参数
Route::get('find/{id}', function ($id) {
    return '输入的id为' . $id;
});
Route::get('find2 /{id?}', function ($id = 0) {
    return '输入的id为' . $id;
});

// 重定向
Route::redirect('/hello', '/');
// 路由别名
Route::get('textad/adl', function () {
    return 'hello';
})->name('123');
// 路由分组
// Route::get('admin/hello', function () {
//     return "欢迎页面";
// });
// Route::get('admin/login', function () {
//     return "登录页面";
// });
// Route::get('/admin', function () {
//     return "超级管理后台";
// });
// 这是管理员后台页面
Route::group(['prefix' => 'admin'], function () {
    Route::get('/', function () {
        return "超级管理后台";
    });
    Route::get(' hello', function () {
        return "欢迎页面";
    });
    Route::get('login', function () {
        return "登录页面";
    });
});
Route::get('admin/testx1', 'Admin\TestController@testx1');
Route::get('text1/input', 'Admin\MyController@input');
//   Route::get('text1/input/{name}','Admin\MyController@input');
Route::get('admin/input/{name}', 'TestController@input');
// 视图文件控制器路由
Route::get('shop/index', 'MyController@shop');
//csrf验证路由
Route::get('test/form', 'TestController@form')->middleware('tset');
Route::post('test/transfer', 'TestController@transfer')->name('trans');

Route::get('test/profile', 'TestController@profile');
Route::post('test/store', 'TestController@store')->name('store');
Route::get('testSession', 'TestController@testSession');

Route::group(['middleware' => ['test']], function () {
    Route::get('/', function () {
        return view('welcome');
    });
});

Route::get('user/login','UserController@login');
Route::post('user/check','UserController@check')->name('check');
Route::get('user/index','UserController@index')->middleware('user');
Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
Route::get('test/database','TestController@database');
Route::get('test/storeDatabase','TestController@storeDatabase');

//文件上传路由
Route::get('txt/avatar','ShopController@avatar');
Route::post('txt/up','ShopController@up');

Route::get('test/captcha','TestController@captcha');
Route::post('test/checkCaptcha','TestController@checkCaptcha');

//缓存
Route::get('test/cache','TestController@cache');

//数据交换格式
Route::get('test/xmldata','TestController@xmldata');
Route::get('test/xml','TestController@xml');

Route::get('test/jsondata','TestController@jsondata');
Route::get('test/json','TestController@json');